package com.gmrz.uap.resource;

import com.gmrz.uap.cfg.SystemConst;
import com.gmrz.uap.common.UAPSSOHelper;
import com.gmrz.uap.model.Resource;
import com.gmrz.uap.model.User;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

import java.util.List;

public class ResourceInterceptor implements Interceptor {
    public void intercept(Invocation inv) {
        //User user = inv.getController().getSessionAttr(SystemConst.SESSION_USER);

        User user = UAPSSOHelper.getUserByUapSessionId(inv.getController().getRequest());

        String pid = inv.getController().getPara();
        List<Resource> resourceList = Resource.dao.findByUserIdAndType(user.getUserId(),2,pid);
        inv.getController().setAttr("resourceList",resourceList);
        inv.getController().setAttr("paramResourceId",pid);
        inv.invoke();
    }
}
